package com.lvy.hczn.front.system.service.impl;

import java.util.List;

import com.lvy.hczn.front.common.utils.DateUtils;
import com.lvy.hczn.front.system.domain.business.PackSpu;
import com.lvy.hczn.front.system.service.PackSpuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lvy.hczn.front.system.mapper.PackSpuMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lvy.hczn.front.common.core.text.Convert;

/**
 * 商品关联的包装袋Service业务层处理
 *
 * @author ruoyi
 * @date 2023-07-18
 */
@Service
@Slf4j
public class PackSpuServiceImpl extends ServiceImpl<PackSpuMapper, PackSpu> implements PackSpuService {

    @Autowired
    private PackSpuMapper packSpuMapper;

    /**
     * 查询商品关联的包装袋
     *
     * @param id 商品关联的包装袋主键
     * @return 商品关联的包装袋
     */
    @Override
    public PackSpu selectPackSpuById(String id) {
        return packSpuMapper.selectById(id);
    }

    /**
     * 查询商品关联的包装袋列表
     *
     * @param packSpu 商品关联的包装袋
     * @return 商品关联的包装袋
     */
    @Override
    public List<PackSpu> selectPackSpuList(PackSpu packSpu) {
        return packSpuMapper.selectPackSpuList(packSpu);
    }

    /**
     * 新增商品关联的包装袋
     *
     * @param packSpu 商品关联的包装袋
     * @return 结果
     */
    @Override
    public int insertPackSpu(PackSpu packSpu) {
        return packSpuMapper.insert(packSpu);
    }

    /**
     * 修改商品关联的包装袋
     *
     * @param packSpu 商品关联的包装袋
     * @return 结果
     */
    @Override
    public int updatePackSpu(PackSpu packSpu) {
        return packSpuMapper.updateById(packSpu);
    }

    /**
     * 批量删除商品关联的包装袋
     *
     * @param ids 需要删除的商品关联的包装袋主键
     * @return 结果
     */
    @Override
    public int deletePackSpuByIds(String ids) {
        String[] idArr = Convert.toStrArray(ids);
        for (String id : idArr) {
            packSpuMapper.deleteById(id);
        }
        return idArr.length;
    }

    /**
     * 删除商品关联的包装袋信息
     *
     * @param id 商品关联的包装袋主键
     * @return 结果
     */
    @Override
    public int deletePackSpuById(String id) {
        return packSpuMapper.deleteById(id);
    }
}
